<?php
namespace PFBC\Element;

class Matrix extends \PFBC\OptionElement {
	//protected $attributes = array("class" => "pfbc-select");

//	public function render() {
//		if(isset($this->attributes["value"])) {
//			if(!is_array($this->attributes["value"]))
//				$this->attributes["value"] = array($this->attributes["value"]);
//		}
//		else
//			$this->attributes["value"] = array();
//
//		if(!empty($this->attributes["multiple"]) && substr($this->attributes["name"], -2) != "[]")
//			$this->attributes["name"] .= "[]";
//
//		echo '<select', $this->getAttributes(array("value", "selected")), ' style="'.$this->style.'">';
//		foreach($this->options as $value => $text) {
//			echo '<option value="', $this->filter($value), '"';
//			$selected = false;
//			if(in_array($value, $this->attributes["value"]))
//				echo ' selected="selected"';
//			echo '>', $text, '</option>';
//		}	
//		echo '</select>';
//	}
        public function render(){
            $array = explode('"',$this->getAttributes("value"));
            $name = $array[1];
            $class = '';
            if($this->attributes['title'] != '')
                    $class = 'vtip';
            echo '<table border="0" cellspacing="5" cellpadding="5" title="', $this->attributes["title"], '" id="', $this->attributes["id"], '" class="'.$class.'">';
            echo '<tr><td>&nbsp;</td>';
            $table = $this->options;
            foreach($table['column'] as $row)
            echo '<td>'.$row.'</td>';
            echo '<tr>';
            $stt = 1;
            foreach($table['row'] as $row){
                echo '<tr align="center"><td>'.$row.'</td>';
                foreach($table['column'] as $ro)
                    echo '<td><input type="radio" name="'.$name.'['.$stt.']" value="'.$row.' : '.$ro.'"></td>';
                echo '</tr>';
                $stt++;
            }
            echo '</table>';
        }
}
